// gerador de estilos para as classes utilitarias padrão
@mixin generate_utility_styles($properties, $value, $property-class, $property-class-modifier, $infix: '') {
  .#{$property-class+$infix+$property-class-modifier} {
    @if type-of($properties) == "string" {
      #{$properties}: $value !important;
    } @else {
      @each $property in $properties {
        #{$property}: $value !important;
      }
    }
  }
}

// gerador de classes utilitarias.
@mixin generate_utilities($utility_key: '', $utility, $is_responsive: false, $infix: '') {
  $values: map-get($utility, values);
  $infix: generate_breakpoint_infix($infix, $media_breakpoints);

  @if type-of($values) == "string" or type-of(nth($values, 1)) != "list" {
    $values: zip($values, $values);
  }

  @each $key, $value in $values {
    $properties: map-get($utility, property);
    $property-class: if(map-has-key($utility, class), map-get($utility, class), nth($properties, 1));
    $property-class: if($property-class == null, "", $property-class);
    $property-class-modifier: if(map-get($utility, class) == null or map-get($utility, using_key), if($property-class == "", "", "-") + $key, "");
    $responsive-utility: if(map-has-key($utility, responsive), map-get($utility, responsive), false);

    // se o mixin não foi utilizado dentro de um gerador de media queries, a variavel $is_responsive deve ser setada como false
    // caso contrario o mixin ira gerar classes com prefixos de breakpoints.
   
    @if $is_responsive == false {
      @include generate_utility_styles($properties, $value, $property-class, $property-class-modifier);
    } @else {
      @if $responsive-utility {
        @include generate_utility_styles($properties, $value, $property-class, $property-class-modifier, $infix);
      }
    }
  }
}

@mixin include_utilities() {
  // gerar as classes utilitarias sem o prefixo de breakpoint.
  @each $utility_key, $utility in $utilities {
    @include generate_utilities($utility_key, $utility);
  }

  // percorrer o map de breakpoints, e passar os valores dos breakpoints para o mixin generate_breakpoints_up
  // para gerar as classes utilitarias responsivas com os prefixos de breakpoints.
  @each $breakpoint_key, $breakpoint_value in $media_breakpoints {
    @include generate_breakpoints_up($breakpoint_key, $media_breakpoints) {
      @each $utility_key, $utility in $utilities {
        @include generate_utilities($utility_key, $utility, true, $breakpoint_key);
      }
    }
  }
}


